/* crypto.h */

/********************/
/* CRYPTO-ROUTINES  */
/* for Secure Phone */
/* (C) 2003 by NAH6 */
/********************/

#ifndef __CRYPTO_H
#define __CRYPTO_H
#ifdef __cplusplus
extern "C" {
#endif

/*--------------*/
/*  STRUCTURES  */
/*--------------*/

struct crypto_twofish_state
{
  unsigned long xkey[40];
  unsigned long sbox[1024];
};

struct crypto_sha_state
{
  unsigned long hash[8];
  unsigned long len;
  unsigned long buf[64];
};

/*----*/

struct crypto_tandem_state
{
  unsigned long               aes_xkey[60];
  struct crypto_twofish_state twofish;
  struct crypto_sha_state     sha;
};

/*--------------*/
/*  PROTOTYPES  */
/*--------------*/

void crypto_tandem_setup   (struct crypto_tandem_state *state, \
                            const unsigned long key[8]);
void crypto_tandem_encrypt (const struct crypto_tandem_state *state, \
                            const unsigned long din[4], unsigned long dout[4]);

/*----*/

void crypto_aes_setup   (unsigned long xkey[60], const unsigned long key[8]);
void crypto_aes_encrypt (const unsigned long xkey[60], \
                         const unsigned long din[4], unsigned long dout[4]);

void crypto_twofish_setup   (struct crypto_twofish_state *state, \
                             const unsigned long key[8]);
void crypto_twofish_encrypt (const struct crypto_twofish_state *state, \
                             const unsigned long din[4], unsigned long dout[4]);

/*----*/

void crypto_sha_setup (struct crypto_sha_state *state);
void crypto_sha_add   (struct crypto_sha_state *state, \
                       const unsigned char *din, unsigned long dlen);
void crypto_sha_final (struct crypto_sha_state *state, unsigned char *dout, \
                       unsigned char dlen);

#ifdef __cplusplus
}
#endif
#endif


/*** EOF ***/
